﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rhomble.Data.Users
{
	public static class UserFilters
	{
		#region Order By

		public static IOrderedQueryable<User> DefaultOrder(this IQueryable<User> source)
		{
			return OrderByName(source);
		}

		public static IOrderedQueryable<User> OrderByName(this IQueryable<User> source)
		{
			return source.OrderBy(c => c.LoweredUserName);
		}

		#endregion

		public static IQueryable<User> WithID(this IQueryable<User> source, Guid userID)
		{
			return source.Where(c => c.UserId == userID);
		}

		public static IQueryable<User> WithName(this IQueryable<User> source, string userName)
		{
			return source.Where(c => c.LoweredUserName == userName.ToLower());
		}
	}
}
